using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.ContactsDomain;
using ShivamEMR.Model.DataInterfaces.ContactsDataInterf;
using ShivamEMR.Model;
//using ShivamEMR.Web.Areas.Contacts.Models;

namespace ShivamEMR.Web.Areas.Contacts.Controllers
{   
    public class CultureAndRegionController : Controller
    {
		private readonly ICountryRepository countryRepository;
		private readonly ICultureAndRegionRepository cultureandregionRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public CultureAndRegionController()
        {
            countryRepository = Registry.RepositoryFactory.GetCountryRepository();
            cultureandregionRepository = Registry.RepositoryFactory.GetCultureAndRegionRepository();
        }

        public CultureAndRegionController(ICountryRepository countryRepository, ICultureAndRegionRepository cultureandregionRepository)
        {
			this.countryRepository = countryRepository;
			this.cultureandregionRepository = cultureandregionRepository;
        }

        //
        // GET: /CultureAndRegion/

        public ViewResult Index()
        {
         //   return View(cultureandregionRepository.AllIncluding(cultureandregion => cultureandregion.Country, cultureandregion => cultureandregion.Moneys));
            return View(cultureandregionRepository.All);
        }

        //
        // GET: /CultureAndRegion/Details/5

        public ViewResult Details(int id)
        {
            return View(cultureandregionRepository.Find(id));
        }

        //
        // GET: /CultureAndRegion/Create

        public ActionResult Create()
        {
			ViewBag.PossibleCountries = countryRepository.All;
            return View();
        } 

        //
        // POST: /CultureAndRegion/Create

        [HttpPost]
        public ActionResult Create(CultureAndRegion cultureandregion)
        {
            if (ModelState.IsValid) {
                cultureandregionRepository.InsertOrUpdate(cultureandregion);
                cultureandregionRepository.Save();
                return RedirectToAction("Index");
            } else {
				ViewBag.PossibleCountries = countryRepository.All;
				return View();
			}
        }
        
        //
        // GET: /CultureAndRegion/Edit/5
 
        public ActionResult Edit(int id)
        {
			ViewBag.PossibleCountries = countryRepository.All;
             return View(cultureandregionRepository.Find(id));
        }

        //
        // POST: /CultureAndRegion/Edit/5

        [HttpPost]
        public ActionResult Edit(CultureAndRegion cultureandregion)
        {
            if (ModelState.IsValid) {
                cultureandregionRepository.InsertOrUpdate(cultureandregion);
                cultureandregionRepository.Save();
                return RedirectToAction("Index");
            } else {
				ViewBag.PossibleCountries = countryRepository.All;
				return View();
			}
        }

        //
        // GET: /CultureAndRegion/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(cultureandregionRepository.Find(id));
        }

        //
        // POST: /CultureAndRegion/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            var cr = cultureandregionRepository.Find(id);
            cultureandregionRepository.Delete(cr);
            cultureandregionRepository.Save();
            return RedirectToAction("Index");
        }
    }
}

